package org.hertsig.magiccardmarket.entities;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import lombok.AllArgsConstructor;
import lombok.Delegate;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import org.hertsig.magiccardmarket.entities.Articles.Condition;
import org.hertsig.magiccardmarket.entities.out.ChangeWantsList;
import org.hertsig.magiccardmarket.entities.out.ChangeWantsList.Product;

import com.google.common.collect.Lists;

@Getter @ToString
@AllArgsConstructor @NoArgsConstructor
@XmlRootElement(name="response")
public class Wants implements Iterable<Wants.Want> {
	@Delegate(types=Iterable.class) @XmlElement private List<Want> want;
	
	@Getter @ToString
	@AllArgsConstructor @NoArgsConstructor
	public static class Want {
		@XmlElement private String idWant;
		@XmlElement private Integer amount;
		@XmlElement private Double wishPrice;
		@XmlElement private String idProduct;
		@XmlElement private String idMetaproduct;
		@XmlElement private String type;
		@XmlElement private Language language;
		@XmlElement private Condition minCondition;
		@XmlElement private Boolean isFoil;
		@XmlElement private Boolean isSigned;
		@XmlElement private Boolean isPlayset;
		@XmlElement private Boolean isAltered;
		@XmlElement private Boolean isFirstEd;
		
		/**
		 * @return this entity as a {@link ChangeWantsList.Product}, to easily change this item or add it to another list
		 */
		public ChangeWantsList.Product asProduct() {
			return new Product(idProduct, amount, minCondition, wishPrice, Lists.newArrayList(language.getIdLanguage()), isFoil, isSigned, isAltered, isPlayset, isFirstEd);
		}
	}
	
	@Getter @ToString
	@AllArgsConstructor @NoArgsConstructor
	public static class Language {
		@XmlElement private Integer idLanguage;
		@XmlElement private String langName;
	}
}
